package com.vx.vxbug.services;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.MailException;
import org.springframework.mail.MailSender;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.stereotype.Service;

/**
 * Created with IntelliJ IDEA.
 * User: vx
 * Date: 12/5/13
 * Time: 1:56 AM
 * To change this template use File | Settings | File Templates.
 */
@Service
public class SendMailService{

    @Autowired
    private AsyncMailSender mailSender;

    public static String sender_email = "vxsendmail@gmail.com";

    public void sendEmail(String to, String subject, String body)
            throws MailException {
        SimpleMailMessage message = new SimpleMailMessage();
        message.setTo(to);
        message.setFrom(sender_email);
        message.setSubject(subject);
        message.setText(body);
        mailSender.send(message);
    }
}
